﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Text;

namespace WindowsPhoneApplication1.Converters
{
    public class ImageSizeStandardConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!string.IsNullOrEmpty((string)value))
            {
                string s = (string)value;

                var splitted = s.Split('.');
                if (splitted.Length == 2)
                    return splitted[0] + "_standard." + splitted[1];
                else if (splitted.Length > 2)
                {
                    StringBuilder toRet = new StringBuilder();

                    for (int i = 0; i < splitted.Length - 1; i++)
                    {
                        if (i != 0)
                            toRet.Append(".");
                        toRet.Append(splitted[i]);
                    }
                    toRet.Append("_standard.jpg");

                    return toRet.ToString();
                }
            }
            return "";
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
